package com.hunk.core.auth.entity;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import com.hunk.core.entity.UUIDEntity;

/**User has a many2many relationship with Role.
 * So we extract two many2one relationship from many2many. 
 * Description :<br>
 * 关系表
 * @author HunkDeng
 * @since 2013-4-13
 */
@Entity
@Table(name = "SYS_USER_ROLE")
public class UserRole extends UUIDEntity {
	/**
	 * 
	 */
	private static final long serialVersionUID = -8681740137538997753L;
	
    @ManyToOne(fetch=FetchType.EAGER)
    @JoinColumn(name="USER_ID", nullable=false)
	User user;
    @ManyToOne(fetch= FetchType.EAGER)
    @JoinColumn(name="ROLE_ID", nullable=false)
	Role role;
    
	@Column(name="UPDATE_USER")
    private String updateUser;
	@Column(name="UPDATE_TIME")
    private Date updateTime;
	
	public User getUser() {
		return user;
	}
	public void setUser(User user) {
		this.user = user;
	}
	public Role getRole() {
		return role;
	}
	public void setRole(Role role) {
		this.role = role;
	}
	public String getUpdateUser() {
		return updateUser;
	}
	public void setUpdateUser(String updateUser) {
		this.updateUser = updateUser;
	}
	public Date getUpdateTime() {
		return updateTime;
	}
	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}
	@Override
	public String toString() {
		return "UserRole [user=" + user + ", role=" + role + ", updateUser="
				+ updateUser + ", updateTime=" + updateTime + ", id=" + id
				+ "]";
	}
	
}
